#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys, urllib, urllib2, json

url = 'http://api.tianapi.com/meinv/?key=40938deee111aeebccccdafcf181d9ed&num=20'

req = urllib2.Request(url)

resp = urllib2.urlopen(req)
content = resp.read()
if(content):
	print(content)

data = json.loads(content)
newlist = data['newslist']
for entry in newlist:
	filename = '%s.jpg'%(entry['title'])
	urllib.urlretrieve(entry['picUrl'], filename)